<?php
/*
* Author：鑫宇工作室
* QQ：639519801
* url：www.xinyuream.com
*/
include_once $_SERVER['DOCUMENT_ROOT'].'/func/include.php';
$user=admin_check(true);
?>
<div class="layuimini-main">

    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">卡密类型</label>
            <div class="layui-input-block">
                <select name="stype" lay-verify="required" lay-reqtext="请选择卡密类型">
					<option value="1">天卡</option>
					<option value="2">周卡</option>
					<option value="3">月卡</option>
					<option value="4">年卡</option>
				</select>
            </div>
        </div>
		<div class="layui-form-item">
            <label class="layui-form-label required">添加数量</label>
            <div class="layui-input-block">
                <select name="setnum" lay-verify="required" lay-reqtext="请选择生成数量">
					<option value="5">5  张</option>
					<option value="10">10 张</option>
					<option value="20">20 张</option>
					<option value="50">50 张</option>
					<option value="100">100张</option>
					<option value="200">200张</option>
				</select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">备注</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="info" value="">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认添加</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table','laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
			laydate =layui.laydate
            $ = layui.$;
        form.render();
		laydate.render({
		  elem: '#date', //元素的id
		  type:'datetime'
		});
        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;
        //监听提交
        form.on('submit(saveBtn)', function (data) {
			$.post({
				url:'/admin?ac=addcard',
				data: data.field,
				type:'post',
				dataType:'json',
				success:function(e){
					layui.exit(e);
					if(e.code===200){
						layer.msg(e.msg,{icon: 6,time: 2000});
						parent.layui.table.reload('datalist');
						layer.close(parentIndex);
					}else{
						layer.msg(e.msg,{icon: 5,time: 2000});
					}
				},
				error: function(e){
				  layer.msg('数据异常，操作失败！',{icon: 5,time: 2000});
				  
				}
			});

            return false;
        });

    });
</script>